<template>
  <div class="basicInformation">
    <div class="operation">
      <div class="operationLeft">
        <!-- <el-input class="inline-input" v-model="userSearchModel.name" @input="querySearch" placeholder="请输入姓名" style="width:220px"></el-input> -->

        <el-input class="inline-input" v-model="userSearchModel.phone" @input="querySearch" placeholder="请输入手机号" style="width:220px"></el-input>
      </div>
    </div>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="用户名" prop="wechatNickname"></el-table-column>
      <el-table-column label="性别">
        <template slot-scope="scope">{{scope.gender ==1 ? '女' : '男'}}
        </template>
      </el-table-column>
      <el-table-column label="联系电话" prop="phone"> </el-table-column>
      <el-table-column label="余额" prop="surplus"> </el-table-column>
      <el-table-column label="积分" prop="integral"> </el-table-column>
      <el-table-column label="注册时间" prop="ctime"> </el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="handleEdit(scope.$index, scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="this.currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="this.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="this.total" background class="turnPage">
    </el-pagination>
  </div>
</template>

<script>
import { getUserList } from "@/api/getData";
export default {
  name: "UsetList",
  data() {
    return {
      userSearchModel: {
        name: '',
        phone: ''
      },
      tableData: [],
      total: 0,
      currentPage: 1,
      pageSize: 10
    };
  },

  methods: {
    querySearch(val){
      this.userSearchModel.phone = val
      this.getUserList()
    },
    handleEdit(index, row) {
      this.$router.push({
        path: "/user-detail",
        query: { 
          userId: row.wechatOpenId,
          phone:row.phone
        },
      });
    },
    handleDelete(index, row) {
      this.$confirm("确认删除该患者吗?", "删除确认", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
      });
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.getUserList()
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getUserList()
    },
    //用户列表
    getUserList(){
      const params = {
        name: this.userSearchModel.name,
        phone:this.userSearchModel.phone,
        currentPage: this.currentPage,
        pageSize: this.pageSize
      };
      getUserList(params).then((res) => {
        console.log(res)
        this.tableData = res.data.list
        this.total = res.data.total
      });
    }
  },
  mounted() {
    this.getUserList()
  },
};
</script>

<style lang="scss" scoped>
.accountList-dialog ::v-deep {
  .el-dialog {
    width: 30%;
    max-width: 368px;
    border-radius: 10px;
    overflow: hidden;
    .el-dialog__header {
      padding: 0;
      height: 50px;
      text-align: center;
      background: #ededed;
      .el-dialog__title {
        font-size: 18px;
        color: #8e8e8e;
        line-height: 50px;
      }
    }
    .el-dialog__body {
      padding: 0 60px;
      > div {
        display: flex;
        margin-top: 30px;
        label {
          width: 60px;
          line-height: 44px;
          font-size: 18px;
        }
        .el-input__inner {
          height: 44px;
          width: 100%;
          font-size: 18px;
        }
        .el-select {
          width: 100%;
          margin: 0;
          font-size: 18px;
        }
      }
    }
    .el-dialog__footer {
      text-align: center;
      border-top: 1px solid #ededed;
      margin-top: 30px;
      padding: 30px 0;
      .el-button {
        width: 98px;
      }
    }
  }
}
.basicInformation {
  padding: 0 56px;
  .title {
    font-size: 20px;
    color: #3c3c3c;
    margin: 40px 0;
  }
  .operation {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;

    .operationLeft {
      .el-input {
        margin-right: 20px;
      }
    }

    .operationBtn {
      width: 128px;
      height: 39px;
      background: #24bbd3;
      color: #fff;
      font-size: 18px;
      padding: 0;
    }
  }
  .turnPage {
    text-align: right;
    margin-top: 20px;
  }

  .el-table::v-deep {
    thead th:first-child,
    tbody td:first-child {
      padding-left: 40px;
    }
  }
}
</style>